Skip to content

feat: improve inline file viewing#102

Merged
DenizAltunkapan merged 2 commits into
Vault-Web:mainfrom
arnabnandy7:feature/media-pdf-viewer
Jul 19, 2026
Merged

feat: improve inline file viewing#102
DenizAltunkapan merged 2 commits into
Vault-Web:mainfrom
arnabnandy7:feature/media-pdf-viewer

Conversation

@arnabnandy7

@arnabnandy7 arnabnandy7 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Improves the existing inline file-view endpoint for images, video, audio, and PDFs.
  • Reuses the existing FileService.loadAsResource() flow.
  • Adds inline content disposition, MIME type, ETag, and last-modified headers.
  • Supports HTTP byte-range requests for media seeking and partial PDF loading.
  • Encodes filenames safely in UTF-8, including spaces and non-ASCII characters.
  • Documents viewer integration and existing file-action endpoints.
  • Adds controller coverage for real resource loading, traversal and symlink escapes, MIME fallback, full/open/suffix/unsatisfiable ranges, and encoded filenames.

Linked issue

Part of #98

Frontend authentication integration is tracked in Vault-Web/vault-web#281.

How to test

  1. Run the test suite:

    cd backend
    ./mvnw test
  2. Request a supported file:

    GET /api/files/view?path=video.mp4
    Authorization: Bearer <token>
  3. Verify the response includes the correct Content-Type, Content-Disposition: inline, ETag, and Last-Modified headers.

  4. Send full, open, suffix, and unsatisfiable byte-range requests. Verify valid ranges return 206 Partial Content with Content-Range, while an out-of-bounds range returns 416.

  5. Verify unknown MIME types return application/octet-stream.

  6. Verify traversal and symlink paths outside the authenticated user root are rejected.

Notes / Risk

  • No database migrations or feature flags are required.
  • Existing download, rename, move, delete, and folder-listing APIs are unchanged.
  • The frontend viewer shell and sidebar still need to be implemented in Vault Web.
  • Native media elements cannot attach an arbitrary bearer-token header. The authenticated same-origin route is tracked in Add authenticated same-origin proxy for workspace file previews vault-web#281.

Signed-off-by: Arnab Nandy <arnab_nandy7@yahoo.com>

@DenizAltunkapan DenizAltunkapan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The backend changes here are reasonable: reusing loadAsResource removes duplication and is stricter (it adds a readable check), the ETag and Last-Modified handling is clean, ContentDisposition.inline() is better than manual string building, and the range-response test is a nice end-to-end confirmation. One blocker and a few test gaps before this can go in.

Blocker: this PR sets Closes #98, but #98 is the full workspace file viewer (viewer shell, per-type renderers, actions sidebar, next/previous navigation, unsupported-type fallback UI, loading and error states). This PR is backend only, and the description itself says the frontend viewer shell still needs to be implemented. Merging it would auto-close #98 with almost all of its acceptance criteria still open. Please change Closes #98 to Part of #98 (or point it at a smaller backend-scoped issue) so the viewer work stays tracked.

Separately, the bearer-token point in your notes is worth a dedicated follow-up issue: native

The inline comments cover the test gaps.

Comment thread backend/src/test/java/cloudpage/controller/FileControllerTest.java
Comment thread backend/src/main/java/cloudpage/controller/FileController.java
Comment thread backend/src/test/java/cloudpage/controller/FileControllerTest.java Outdated
Comment thread backend/src/test/java/cloudpage/controller/FileControllerTest.java
Signed-off-by: Arnab Nandy <arnab_nandy7@yahoo.com>

@DenizAltunkapan DenizAltunkapan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arnabnandy7 thanks!

@DenizAltunkapan
DenizAltunkapan merged commit 7330fcc into Vault-Web:main Jul 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants